home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 February
/
Macworld (1999-02).dmg
/
Cinema 4D GO demo
/
Gumption Plug-ins
/
Plug-ins
/
Freeware
/
Path2Spline
/
path2spl.cof
< prev
next >
Wrap
Text File
|
1998-06-16
|
3KB
|
114 lines
// Konversion von objektpositionen zu einem spline
//
// Motion Gimmick
//
// Autor: Roland Fietkau
//
class Tuserinput
{
public:
var close;
var framestart,frameend;
var name;
var tangents;
var cancelled;
}
HandleUserDialog(objname,s,e)
{
var ui=new(Tuserinput);
// defaultwerte
ui->close=FALSE;
ui->tangents=TRUE;
ui->framestart=s;
ui->frameend=e;
ui->name="path";
ui->cancelled=FALSE;
var sd=new(SimpleDialog);
var z1=stradd("Path from: ",objname);
sd->SetTitle(z1);
sd->SetData(0,"First Frame",FIELD_INTEGER,s,e,ui->framestart);
sd->SetData(5,"Last Frame",FIELD_INTEGER,s,e,ui->frameend);
sd->SetData(1,"Close Spline? ",FIELD_STRING,0,0,"No");
sd->SetData(2,"Name ",FIELD_STRING,0,0,"path");
sd->SetData(6,"Set Tangents?",FIELD_STRING,0,0,"Yes");
if (sd->DoDialog())
{
ui->framestart=sd->GetData(0);
ui->frameend=sd->GetData(5);
ui->name=sd->GetData(2);
ui->close= !(0 == strcmp(sd->GetData(1),"No"));
ui->tangents= (0 == strcmp(sd->GetData(6),"Yes"));
}
else
{
ui->cancelled=TRUE;
};
return(ui);
}
mymain(doc)
{
var obj1=doc->FindFirstActiveObject();
if ((!obj1) )
{
TextDialog( "Need activated Object",DLG_OK+DLG_ICONEXCLAMATION);
TextDialog( "Don¥t try that again!",DLG_OK+DLG_ICONEXCLAMATION);
}else
{ //wir haben aktiviertes objekt
var ui=HandleUserDialog(obj1->GetName(),0,int(doc->GetMaxTime()*doc->GetFps()));
if (!ui->cancelled)
{
var splpointcount=1 + abs( ui->frameend - ui->framestart);
var nspl=doc->NewSplineObject(ui->name,NULL,NULL,splpointcount);
var nsplinfo=new(SplineInfo);
nsplinfo->number=5;
nsplinfo->inter=0;
nsplinfo->closed=ui->close ;
nsplinfo->type=SPL_HERMITE ;
nspl->SetSplineInfo(nsplinfo);
//und los
var t=float(ui->framestart) / doc->GetFps();
var dt= ( (ui->frameend>=ui->framestart)? 1.0 : -1.0) /doc->GetFps();
var k=0;
var mmm=new(Matrix);
for (; (k<splpointcount) ; t+=dt,k+=1)
{
doc->SetTime(t,41); //41 ist meine Schuhgroesse
obj1->GetUpMg(mmm);
var ppkt=obj1->GetPosition();
ppkt=mmm->MulP(ppkt);
nspl->SetPoint(k,ppkt,vector(0),vector(0));
};
if (ui->tangents)
{
doc->ActivateObject(nspl); //Aktivieren sonst ...
nspl->SetDefaultTangents(TRUE); //... hier uebler Absturz
};
nspl->UpdateObject();
doc->SendMessage(DOCUMENT_CHANGED);
doc->SendMessage(REDRAW_ALL);
}
};
}
main()
{
RegisterMenuHook("Path_2_Spl","mymain");
};